package com.smart_campus.sys.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.smart_campus.sys.common.DataGridView;
import com.smart_campus.sys.vo.LoginfoVo;
import com.smart_campus.sys.vo.NoticeVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.smart_campus.sys.mapper.NoticeMapper;
import com.smart_campus.sys.domain.Notice;
import com.smart_campus.sys.service.NoticeService;

import java.util.List;

/**
 * @aytgor 陈鹏
 * @date 2020/6/9 10:41
 */
@Service
public class NoticeServiceImpl implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    /**
     * @param noticeVo
     * @return DataGridView
     * 公告分页方法
     */
    @Override
    public DataGridView selectNotice(NoticeVo noticeVo) {
        Page<Object> page = PageHelper.startPage(noticeVo.getPage(), noticeVo.getLimit());//分页数据格式
        List<NoticeVo> noticeVos = noticeMapper.selectNotice(noticeVo);//返回的全部数据
        return new DataGridView(page.getTotal(), noticeVos);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return noticeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Notice record) {
        return noticeMapper.insert(record);
    }

    @Override
    public int insertSelective(Notice record) {
        return noticeMapper.insertSelective(record);
    }

    @Override
    public Notice selectByPrimaryKey(Integer id) {
        return noticeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Notice record) {
        return noticeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Notice record) {
        return noticeMapper.updateByPrimaryKey(record);
    }

}
